package com.wmapp.domain;

import com.wmapp.utils.Pserver;
import com.wmapp.utils.SimpleStringUtils;
/**
 * Participant domain
 * used by AddressBook module
 * @author dengl
 *
 */
public class Participant {
	private String number;
	private String name;
	private String password;
	private String group;
	private String bandwidth;
	private String reachable; //boolean
	private String registered; //boolean
	private String incall; //boolean
	private String outgoing;//boolean
	private String ip;
	private String email;
	private String driver;
	private String description;
	private String data;
	
	private String states;//to display "reachable" "registered" "incall" state with image
	private String incallImg;//Show calling.gif image base on incall field
	
	private String videoEnable="1";//for conference control module
	
	public static final String[] ADD_PARAM_FIELDS={"number","name","password","group","bandwidth","ip","email","description"};
	public final static String[] MODIFY_PARAM_FIELDS={"number","name","password","group","bandwidth","ip","email","description"};
	public final static String[] GRID_COLS={"number","name","states","group","bandwidth","ip","email"};
	
	public final static String[] GRID_COLS_FOR_INVITE={"number","name","ip","videoEnable","bandwidth","states"};
	public final static String[] GRID_COLS_FOR_VIEW={"number","name","driver","incallImg","data"};
	
	public String getNumber() {
		return number;
	}
	public void setNumber(String number) {
		this.number = number;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getGroup() {
		return group;
	}
	public void setGroup(String group) {
		this.group = group;
	}
	public String getBandwidth() {
		return bandwidth;
	}
	public void setBandwidth(String bandwidth) {
		this.bandwidth = bandwidth;
	}
	public String getReachable() {
		return reachable;
	}
	public void setReachable(String reachable) {
		this.reachable = reachable;
	}
	public String getRegistered() {
		return registered;
	}
	public void setRegistered(String registered) {
		this.registered = registered;
	}
	public String getIncall() {
		return incall;
	}
	public void setIncall(String incall) {
		this.incall = incall;
	}
	
	public String getStates() {
		StringBuffer ret=new StringBuffer();
		
		if(this.reachable!=null&&this.reachable.equals("true")){//online
			ret.append(SimpleStringUtils.join("<span title='$img.tip.online'><img src='",Pserver.getInstance().getContextPath(),"/styles/default/images/power_on.png' /></span>"));
		}
		if(this.registered!=null&&this.registered.equals("true")){//registered
			ret.append(SimpleStringUtils.join("<span title='$img.tip.registed'><img src='",Pserver.getInstance().getContextPath(),"/styles/default/images/accept.png' /></span>"));
		}
		if(this.incall!=null&&this.incall.equals("true")){//in call
			ret.append(SimpleStringUtils.join("<span title='$img.tip.incall'><img src='",Pserver.getInstance().getContextPath(),"/styles/default/images/chat.png' /></span>"));
		}
		return ret.toString();
	}
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getOutgoing() {
		return outgoing;
	}
	public void setOutgoing(String outgoing) {
		this.outgoing = outgoing;
	}
	public String getDriver() {
		return driver;
	}
	public void setDriver(String driver) {
		this.driver = driver;
	}
	public String getData() {
		return data;
	}
	public void setData(String data) {
		this.data = data;
	}
	public String getVideoEnable() {
		return videoEnable;
	}
	
	public void setVideoEnable(String videoEnable) {
		this.videoEnable = videoEnable;
	}
	
	public String getIncallImg() {
		StringBuffer ret=new StringBuffer();
		if(this.incall!=null&&this.incall.equals("true")){
			ret.append(SimpleStringUtils.join("<span title='$img.tip.incall'><img src='",Pserver.getInstance().getContextPath(),"/styles/default/images/chat.png' /></span>"));
		}
		
		return ret.toString();
	}
	
}
